<%@page language="java" contentType="text/html; charset=utf-8"%>
<%@include file="/tagDeclare.jsp"%>
<%@include file="/headDeclare.jsp"%>
<html>
 <head>
  <title>权限列表</title>
<style type="text/css"> 
	fieldset,table,tr,td {margin:0; padding:0;}
	td {padding:0 5px 0 10px;border:1px;}
	form label {font-weight:bold;}
	table{border-collapse: collapse;}
  </style>

  <script type="text/javascript">
	$(document).ready(function() { 
        $("#btn_search").click(function(){
            $("#curPage").val(1);
            $("#rightForm").submit();
        });

	}); 
	function insert(){
		var pid = $("#pid").val();
        $.ligerDialog.open({ url: 'right/insert.do?pid='+pid, height: 300, width: 400, buttons: [
            { text: '确定', onclick: function (item, dialog) {
            	dialog.frame.$("form:first").submit();
            },cls:'l-dialog-btn-highlight' },
            { text: '取消', onclick: function (item, dialog) { dialog.close(); } }
         ], isResize: true,title:'新增'
        });
    }
	
	function showItem(id){
        $.ligerDialog.open({ url: 'right/view.do?id='+id, height: 300, width: 400, buttons: [
            { text: '确定', onclick: function (item, dialog) {
            	dialog.close();
            },cls:'l-dialog-btn-highlight' },
            { text: '取消', onclick: function (item, dialog) { dialog.close(); } }
         ], isResize: true,title:'查看'
        });
    }
	
	function updateItem(id){
        $.ligerDialog.open({ url: 'right/update.do?id='+id, height: 300, width: 400, buttons: [
            { text: '确定', onclick: function (item, dialog) {
            	dialog.frame.$("form:first").submit();
            },cls:'l-dialog-btn-highlight' },
            { text: '取消', onclick: function (item, dialog) { dialog.close(); } }
         ], isResize: true,title:'修改'
        });
    }
	
	function deleteItem(id,pid){
		var url = "<%=basePath%>right/delete.do";
		$.post(url,{id:id,pid:pid},function(data){
			var responseJson = eval('(' + data + ')');
			   if(responseJson.code==0)
			   {
				   $.ligerDialog.error("删除出错");
	         		return;
			   }else{
		    		window.parent.frames["righttree"].location.reload();
		    		window.pagerForm.submit();
			   }
		});
    	
	}
	
  </script>
 </head>

 <body>
 
 <div style="width: 100%;">
  <div style="margin: auto;margin-top: 10px;" >
      <form id="rightForm"  method="post" action="right/list.do">
        <table>
          <tr>
            <td><label for="name">权限名称:</label></td>
            <td><input type="text" name="rightname" id="rightname" value="${rightname }" class="ldText" /></td>
            <td><input type="submit" id="btn_search" class="ldBtnBlue" name="btn_search" value="查询" /></td>
          </tr>
        </table>
        <input type="hidden" name="pid" id="pid" value="${pid }" />
        <input type="hidden" name="curPage" id="curPage" value="${curPage}" />
      </form>
  </div>
  <hr />
  <div>
  	<table border="0" cellspacing="0" cellpadding="0" width="100%" class="ld-datagrid">
	    <tr>
	    	<th>序号</th>
          <th>权限名称</th>
          <th>权限标识</th>
          <th>权限URL</th>
          <th>操作</th>
 	    </tr> 
	  	<c:forEach items="${list}" var="right" varStatus="status">
	  	<tr>
	  	  <td>${status.count}</td>
	  	  <td >
	  	  	${right.rightName }
	  	  </td>
	  	  <td >${right.rightMark }</td>
	  	  <td >
			${right.rightUrl }
		  </td>
	  	  <td >
	  	  	<input type="button" onclick="showItem('${right.id }')" value="查看" class="ldBtnLink" />
	  	  	<input type="button" onclick="updateItem('${right.id }')" value="修改" class="ldBtnLink" />
	  	  	<input type="button" onclick="deleteItem('${right.id }','${right.upRightId }')" value="删除" class="ldBtnLink" />
	  	  </td>
	  	</tr>
	  	</c:forEach>
  	</table>
  </div>
	<hr />
  <div>
  <div style="float: left;">
  	 <input type="button" onclick="insert()" class="ldBtnGray" value="新增" o />
  </div>
      <div style="text-align:right;">
      <form action="right/list.do" id="pagerForm" name="pagerForm" >
      	<input type="hidden" name="rightName" value="${rightName }" />
      	<input type="hidden" name="pid" value="${pid }" />
       	<jt:pager action="pagerForm"></jt:pager>
       </form>
      </div>
  </div>
 </div>
 </body>
</html>

